import datetime

def makeInsert(table, args):
    global everything
    
    printMe = "insert into bouting_" + table + " values("
    lastNull = False
    
    print args
    for arg in args:
        if arg == "":
            printMe = printMe + "NULL, "
            lastNull = True
        else:
            printMe = printMe + "'" + str(arg) + "', "
            lastNull = False
    
    if not lastNull:
        printMe = printMe[:-2]
    else:
        printMe = printMe[:-2]
    printMe = printMe + ");"
    everything = everything + printMe + "\n"
    

everything = "delete from bouting_weaponrating;\n"
everything = everything + "delete from bouting_refrating;\n"
everything = everything + "delete from bouting_section;\n"
everything = everything + "delete from bouting_division;\n"
everything = everything + "delete from bouting_club;\n"
everything = everything + "delete from bouting_person;\n"
everything = everything + "delete from bouting_usfacard;\n"

# Insert all the ref ratings
u = 0
for i in range(49,58):
    for c in range(2007, 2012):
        makeInsert("refrating",  (u,chr(i),c))
        u = u+1
        
for c in range(2007, 2012):
    makeInsert("refrating",  (u,"10",c))
    u = u+1

# Insert all the weapon ratings
#u = 0
for i in range(65,70):
    for c in range(2007, 2012):
        makeInsert("weaponrating",  (u,chr(i),c))
        u = u+1
makeInsert("weaponrating", ("25","U", ""))

# Insert a section
makeInsert("section", ["Mid-Atlantic"])

# Insert a division
makeInsert("division", ["Maryland"])
makeInsert("division", ["Virginia"])

# Insert a club
makeInsert("club", ("0", "Fencing Club A", "FCA", "Maryland", "Severn", "Maryland", "888 Nowhere Plaza", "http://www.website.net", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("club", ("1", "Fencing Club B", "FCB", "Maryland", "Severn", "Maryland", "777 Unknown Road", "http://www.internet.org", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("club", ("2", "Fencing Club C", "FCC", "Virginia", "Severn", "Maryland", "666 Circle Court", "http://www.fencing.org", "1", datetime.datetime.now(), "1", datetime.datetime.now()))

makeInsert("person", ("1", "Adam", "Adams", "M", "", "", "0", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("person", ("2", "Bridgette", "Brown", "F", "", "", "0", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("person", ("3", "Cathy", "Curuthers", "F", "", "", "1", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("person", ("4", "Diana", "Dailey", "F", "", "", "2", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("person", ("5", "Ethan", "Evers", "M", "", "", "1", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("person", ("6", "Francis", "Foley", "M", "", "", "0", "", "", "1", datetime.datetime.now(), "1", datetime.datetime.now()))


# Insert some cards
makeInsert("usfacard", ("1", "111111112", "Maryland", "0", "2011-05-13", "2014-07-23", "53", "52", "64", "", "", "", "1", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("usfacard", ("2", "111111113", "Maryland", "0", "2011-07-23", "2015-07-23", "63", "52", "73", "", "", "", "2", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("usfacard", ("3", "111111114", "Virginia", "0", "2012-05-23", "2013-07-23", "53", "54", "74", "", "", "", "3", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("usfacard", ("4", "111111115", "Maryland", "0", "2011-07-23", "2016-07-23", "55", "52", "64", "", "", "", "4", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("usfacard", ("5", "111111116", "Maryland", "0", "2011-12-23", "2017-07-23", "53", "65", "52", "", "", "", "5", "1", datetime.datetime.now(), "1", datetime.datetime.now()))
makeInsert("usfacard", ("6", "111111117", "Maryland", "0", "2011-12-23", "2017-07-23", "53", "65", "52", "", "", "", "6", "1", datetime.datetime.now(), "1", datetime.datetime.now()))


f = open("InsertThis.sql", "w")
f.write(everything)
f.close()
